package web.controller.employer;

import common.consts.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import service.ServiceResponse;
import service.UserProfileService;
import web.Routes;
import web.controller.Base;
import web.security.Protection;

/**
 * Created by aceyin on 15/7/6.
 * 查看应聘者详细资料
 */
@RestController
@RequestMapping(Routes.Employer.APPLIER)
public class Applier extends Base {

    @Autowired
    private UserProfileService userProfileService;

    @Protection
    @RequestMapping(method = RequestMethod.GET, produces = ContentType.JSON)
    public ServiceResponse view(@RequestParam("id") long id,
                                @RequestParam(value = "recruitment", defaultValue = "0") int recruitment) {
        //TODO: verify viewer is equals to the value extracted from Authentication header
        long employer = getUserIdFromAuthHeader();
        return userProfileService.viewCompletedApplierProfile(id, employer, recruitment);
    }
}
